package com.bw.paper.network.interceptor;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class TokenInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        //先获取原有Request
        Request oldRequest = chain.request();
        //配置添加过token的Request
        Request.Builder build = new Request.Builder();
        build.url(oldRequest.url());
        build.headers(oldRequest.headers());

        build.addHeader("token","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI3ODkiLCJleHAiOjMyNDI0OTM2OTAsImlhdCI6MTYyMTI0Njg0NX0.wuAIJQrH9BgNk2rGKCniR_I6NCtO-DkAduhjL-t4i9s");
        build.post(oldRequest.body());
        Request request = build.build();
        return chain.proceed(request);
    }
}
